package hu.bme.mit.mdsd.service.generator;

import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.generator.IFileSystemAccess;
import org.eclipse.xtext.generator.IGenerator;
import org.eclipse.xtext.xbase.lib.BooleanExtensions;
import org.eclipse.xtext.xbase.lib.IntegerExtensions;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
import org.eclipse.xtext.xbase.lib.IteratorExtensions;
import org.eclipse.xtext.xbase.lib.ObjectExtensions;
import org.eclipse.xtext.xbase.lib.StringExtensions;
import system.Attribute;
import system.Entity;
import system.Enumeration;
import system.EnumerationLiteral;
import system.Multiplicity;
import system.NamedQuery;
import system.Platform;
import system.Reference;
import system.TemporalType;
import system.Type;

@SuppressWarnings("all")
public class EntityModelGenerator implements IGenerator {
  private int querynum = 0;
  
  private int enumnum = 0;
  
  public void doGenerate(final Resource input, final IFileSystemAccess fsa) {
    TreeIterator<EObject> _allContents = input.getAllContents();
    Iterable<EObject> _iterable = IteratorExtensions.<EObject>toIterable(_allContents);
    Iterable<system.System> _filter = IterableExtensions.<system.System>filter(_iterable, system.System.class);
    for (final system.System p : _filter) {
      Platform _targetPlatform = p.getTargetPlatform();
      boolean _operator_equals = ObjectExtensions.operator_equals(_targetPlatform, Platform.OS_GI);
      if (_operator_equals) {
        {
          TreeIterator<EObject> _eAllContents = p.eAllContents();
          Iterable<EObject> _iterable_1 = IteratorExtensions.<EObject>toIterable(_eAllContents);
          Iterable<Entity> _filter_1 = IterableExtensions.<Entity>filter(_iterable_1, system.Entity.class);
          for (final Entity e : _filter_1) {
            {
              this.countqueries(e);
              String _name = e.getName();
              String _operator_plus = StringExtensions.operator_plus(_name, ".java");
              CharSequence _compile = this.compile(e, p);
              fsa.generateFile(_operator_plus, _compile);
              this.querynum = 0;
            }
          }
          TreeIterator<EObject> _eAllContents_1 = p.eAllContents();
          Iterable<EObject> _iterable_2 = IteratorExtensions.<EObject>toIterable(_eAllContents_1);
          Iterable<Enumeration> _filter_2 = IterableExtensions.<Enumeration>filter(_iterable_2, system.Enumeration.class);
          for (final Enumeration x : _filter_2) {
            {
              this.countenums(x);
              String _name_1 = x.getName();
              String _operator_plus_1 = StringExtensions.operator_plus(_name_1, ".java");
              CharSequence _compile_1 = this.compile(x, p);
              fsa.generateFile(_operator_plus_1, _compile_1);
              this.enumnum = 0;
            }
          }
        }
      }
    }
  }
  
  public void countqueries(final Entity e) {
    EList<NamedQuery> _namedQueries = e.getNamedQueries();
    for (final NamedQuery f : _namedQueries) {
      int _operator_plus = IntegerExtensions.operator_plus(this.querynum, 1);
      this.querynum = _operator_plus;
    }
  }
  
  public CharSequence compile(final Entity e, final system.System s) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package ");
    String _packageName = s.getPackageName();
    _builder.append(_packageName, "");
    _builder.append(".entities;");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.newLine();
    _builder.append("import javax.persistence.*;");
    _builder.newLine();
    _builder.append("import ");
    String _packageName_1 = s.getPackageName();
    _builder.append(_packageName_1, "");
    _builder.append(".entities.*;");
    _builder.newLineIfNotEmpty();
    _builder.append("import java.util.List;");
    _builder.newLine();
    _builder.append("import java.util.ArrayList;");
    _builder.newLine();
    _builder.newLine();
    _builder.newLine();
    _builder.append("@Entity");
    _builder.newLine();
    {
      String _table = e.getTable();
      boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_table, null);
      if (_operator_notEquals) {
        _builder.append("@Table(name=\"");
        String _table_1 = e.getTable();
        _builder.append(_table_1, "");
        _builder.append("\")");
        _builder.newLineIfNotEmpty();
      }
    }
    {
      boolean _operator_equals = IntegerExtensions.operator_equals(this.querynum, 1);
      if (_operator_equals) {
        _builder.append("@NamedQuery(name=");
        String _name = e.getName();
        _builder.append(_name, "");
        _builder.append(".");
        EList<NamedQuery> _namedQueries = e.getNamedQueries();
        NamedQuery _last = IterableExtensions.<NamedQuery>last(_namedQueries);
        String _queryName = _last.getQueryName();
        _builder.append(_queryName, "");
        _builder.append(", query=\"");
        EList<NamedQuery> _namedQueries_1 = e.getNamedQueries();
        NamedQuery _last_1 = IterableExtensions.<NamedQuery>last(_namedQueries_1);
        String _query = _last_1.getQuery();
        _builder.append(_query, "");
        _builder.append("\")");
        _builder.newLineIfNotEmpty();
      }
    }
    {
      boolean _operator_greaterThan = IntegerExtensions.operator_greaterThan(this.querynum, 1);
      if (_operator_greaterThan) {
        _builder.append("@NamedQueries(");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("{");
        _builder.newLine();
        {
          EList<NamedQuery> _namedQueries_2 = e.getNamedQueries();
          for(final NamedQuery f : _namedQueries_2) {
            {
              EList<NamedQuery> _namedQueries_3 = e.getNamedQueries();
              NamedQuery _last_2 = IterableExtensions.<NamedQuery>last(_namedQueries_3);
              boolean _equals = f.equals(_last_2);
              if (_equals) {
                _builder.append("\t");
                _builder.append("@NamedQuery(name=");
                String _name_1 = e.getName();
                _builder.append(_name_1, "	");
                _builder.append(".");
                String _queryName_1 = f.getQueryName();
                _builder.append(_queryName_1, "	");
                _builder.append(",query=\"");
                String _query_1 = f.getQuery();
                _builder.append(_query_1, "	");
                _builder.append("\")");
                _builder.newLineIfNotEmpty();
              } else {
                _builder.append("\t");
                _builder.append("@NamedQuery(name=");
                String _name_2 = e.getName();
                _builder.append(_name_2, "	");
                _builder.append(".");
                String _queryName_2 = f.getQueryName();
                _builder.append(_queryName_2, "	");
                _builder.append(",query=\"");
                String _query_2 = f.getQuery();
                _builder.append(_query_2, "	");
                _builder.append("\"),");
                _builder.newLineIfNotEmpty();
              }
            }
          }
        }
        _builder.append("\t");
        _builder.append("})");
        _builder.newLine();
      }
    }
    _builder.append("public class ");
    String _name_3 = e.getName();
    _builder.append(_name_3, "");
    _builder.append(" ");
    {
      Entity _superType = e.getSuperType();
      boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_superType, null);
      if (_operator_notEquals_1) {
        _builder.append("extends ");
        Entity _superType_1 = e.getSuperType();
        String _name_4 = _superType_1.getName();
        _builder.append(_name_4, "");
        _builder.append(" ");
      }
    }
    _builder.append("{");
    _builder.newLineIfNotEmpty();
    _builder.append("\t                        \t");
    _builder.newLine();
    {
      EList<NamedQuery> _namedQueries_4 = e.getNamedQueries();
      for(final NamedQuery f_1 : _namedQueries_4) {
        _builder.append("\t");
        CharSequence _compile = this.compile(f_1);
        _builder.append(_compile, "	");
        _builder.newLineIfNotEmpty();
      }
    }
    _builder.newLine();
    _builder.append("\t");
    _builder.append("//Attributes");
    _builder.newLine();
    {
      EList<Attribute> _attributes = e.getAttributes();
      for(final Attribute f_2 : _attributes) {
        _builder.append("\t");
        CharSequence _compile_1 = this.compile(f_2);
        _builder.append(_compile_1, "	");
        _builder.newLineIfNotEmpty();
      }
    }
    _builder.newLine();
    {
      EList<Reference> _references = e.getReferences();
      for(final Reference f_3 : _references) {
        _builder.append("\t");
        CharSequence _compile_2 = this.compile(f_3);
        _builder.append(_compile_2, "	");
        _builder.newLineIfNotEmpty();
      }
    }
    _builder.newLine();
    _builder.newLine();
    _builder.append("\t");
    _builder.append("//Getters and Setters");
    _builder.newLine();
    {
      EList<Attribute> _attributes_1 = e.getAttributes();
      for(final Attribute f_4 : _attributes_1) {
        _builder.append("\t");
        CharSequence _compilegetset = this.compilegetset(f_4);
        _builder.append(_compilegetset, "	");
        _builder.newLineIfNotEmpty();
      }
    }
    _builder.newLine();
    {
      EList<Reference> _references_1 = e.getReferences();
      for(final Reference f_5 : _references_1) {
        _builder.append("\t");
        CharSequence _compilegetset_1 = this.compilegetset(f_5);
        _builder.append(_compilegetset_1, "	");
        _builder.newLineIfNotEmpty();
      }
    }
    _builder.append("}");
    return _builder;
  }
  
  public CharSequence compile(final NamedQuery a) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("public static final String ");
    String _queryName = a.getQueryName();
    _builder.append(_queryName, "");
    _builder.append(" = \"");
    String _name = a.getName();
    _builder.append(_name, "");
    _builder.append("\";");
    _builder.newLineIfNotEmpty();
    return _builder;
  }
  
  public CharSequence compile(final Attribute a) {
    StringConcatenation _builder = new StringConcatenation();
    {
      boolean _isIsId = a.isIsId();
      if (_isIsId) {
        _builder.append("@Id");
        _builder.newLine();
      }
    }
    {
      boolean _isIsTransient = a.isIsTransient();
      if (_isIsTransient) {
        _builder.append("@Transient");
        _builder.newLine();
      }
    }
    {
      boolean _isIsGeneratedValue = a.isIsGeneratedValue();
      if (_isIsGeneratedValue) {
        _builder.append("@GeneratedValue");
        _builder.newLine();
      }
    }
    {
      boolean _operator_and = false;
      String _column = a.getColumn();
      boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_column, "");
      if (!_operator_notEquals) {
        _operator_and = false;
      } else {
        String _column_1 = a.getColumn();
        boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_column_1, null);
        _operator_and = BooleanExtensions.operator_and(_operator_notEquals, _operator_notEquals_1);
      }
      if (_operator_and) {
        _builder.append("@Column(name=\"");
        String _column_2 = a.getColumn();
        _builder.append(_column_2, "");
        _builder.append("\"");
        {
          boolean _isIsUnique = a.isIsUnique();
          boolean _operator_equals = BooleanExtensions.operator_equals(_isIsUnique, true);
          if (_operator_equals) {
            _builder.append(", unique=");
            boolean _isIsUnique_1 = a.isIsUnique();
            _builder.append(_isIsUnique_1, "");
          }
        }
        _builder.append(")");
        _builder.newLineIfNotEmpty();
      } else {
        {
          boolean _isIsUnique_2 = a.isIsUnique();
          boolean _operator_equals_1 = BooleanExtensions.operator_equals(_isIsUnique_2, true);
          if (_operator_equals_1) {
            _builder.append("@Column(unique=");
            boolean _isIsUnique_3 = a.isIsUnique();
            _builder.append(_isIsUnique_3, "");
            _builder.append(")");
            _builder.newLineIfNotEmpty();
          }
        }
      }
    }
    {
      TemporalType _temporal = a.getTemporal();
      boolean _operator_notEquals_2 = ObjectExtensions.operator_notEquals(_temporal, TemporalType.NONE);
      if (_operator_notEquals_2) {
        _builder.append("@Temporal(TemporalType.");
        TemporalType _temporal_1 = a.getTemporal();
        _builder.append(_temporal_1, "");
        _builder.append(")");
        _builder.newLineIfNotEmpty();
      }
    }
    _builder.append("private ");
    Type _type = a.getType();
    String _name = _type.getName();
    _builder.append(_name, "");
    _builder.append(" ");
    String _name_1 = a.getName();
    _builder.append(_name_1, "");
    _builder.append(";");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    return _builder;
  }
  
  public CharSequence compile(final Reference r) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("//Reference to ");
    Entity _referencedEntity = r.getReferencedEntity();
    String _name = _referencedEntity.getName();
    _builder.append(_name, "");
    _builder.newLineIfNotEmpty();
    {
      Multiplicity _multiplicity = r.getMultiplicity();
      boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_multiplicity, null);
      if (_operator_notEquals) {
        _builder.append("@");
        Multiplicity _multiplicity_1 = r.getMultiplicity();
        _builder.append(_multiplicity_1, "");
        {
          boolean _operator_and = false;
          String _mappedBy = r.getMappedBy();
          boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_mappedBy, null);
          if (!_operator_notEquals_1) {
            _operator_and = false;
          } else {
            String _mappedBy_1 = r.getMappedBy();
            boolean _operator_notEquals_2 = ObjectExtensions.operator_notEquals(_mappedBy_1, "");
            _operator_and = BooleanExtensions.operator_and(_operator_notEquals_1, _operator_notEquals_2);
          }
          if (_operator_and) {
            _builder.append("(mappedBy=\"");
            String _mappedBy_2 = r.getMappedBy();
            _builder.append(_mappedBy_2, "");
            _builder.append("\")");
          }
        }
        _builder.newLineIfNotEmpty();
      }
    }
    {
      boolean _operator_and_1 = false;
      String _joinTableName = r.getJoinTableName();
      boolean _operator_notEquals_3 = ObjectExtensions.operator_notEquals(_joinTableName, "");
      if (!_operator_notEquals_3) {
        _operator_and_1 = false;
      } else {
        String _joinTableName_1 = r.getJoinTableName();
        boolean _operator_notEquals_4 = ObjectExtensions.operator_notEquals(_joinTableName_1, null);
        _operator_and_1 = BooleanExtensions.operator_and(_operator_notEquals_3, _operator_notEquals_4);
      }
      if (_operator_and_1) {
        _builder.append("@JoinTable(name = \"");
        String _joinTableName_2 = r.getJoinTableName();
        _builder.append(_joinTableName_2, "");
        _builder.append("\", joinColumns = @JoinColumn(name = \"");
        String _joinColumnName = r.getJoinColumnName();
        _builder.append(_joinColumnName, "");
        _builder.append("\"), inverseJoinColumns = @JoinColumn(name = \"");
        String _inverseJoinColumnName = r.getInverseJoinColumnName();
        _builder.append(_inverseJoinColumnName, "");
        _builder.append("\"))");
        _builder.newLineIfNotEmpty();
      }
    }
    {
      boolean _operator_and_2 = false;
      boolean _operator_or = false;
      String _joinTableName_3 = r.getJoinTableName();
      boolean _operator_equals = ObjectExtensions.operator_equals(_joinTableName_3, null);
      if (_operator_equals) {
        _operator_or = true;
      } else {
        String _joinTableName_4 = r.getJoinTableName();
        boolean _operator_equals_1 = ObjectExtensions.operator_equals(_joinTableName_4, "");
        _operator_or = BooleanExtensions.operator_or(_operator_equals, _operator_equals_1);
      }
      if (!_operator_or) {
        _operator_and_2 = false;
      } else {
        String _joinColumnName_1 = r.getJoinColumnName();
        boolean _operator_notEquals_5 = ObjectExtensions.operator_notEquals(_joinColumnName_1, null);
        _operator_and_2 = BooleanExtensions.operator_and(_operator_or, _operator_notEquals_5);
      }
      if (_operator_and_2) {
        _builder.append("@JoinColumn(name = \"");
        String _joinColumnName_2 = r.getJoinColumnName();
        _builder.append(_joinColumnName_2, "");
        _builder.append("\")");
        _builder.newLineIfNotEmpty();
      }
    }
    {
      boolean _operator_or_1 = false;
      Multiplicity _multiplicity_2 = r.getMultiplicity();
      boolean _operator_equals_2 = ObjectExtensions.operator_equals(_multiplicity_2, Multiplicity.MANY_TO_MANY);
      if (_operator_equals_2) {
        _operator_or_1 = true;
      } else {
        Multiplicity _multiplicity_3 = r.getMultiplicity();
        boolean _operator_equals_3 = ObjectExtensions.operator_equals(_multiplicity_3, Multiplicity.ONE_TO_MANY);
        _operator_or_1 = BooleanExtensions.operator_or(_operator_equals_2, _operator_equals_3);
      }
      if (_operator_or_1) {
        _builder.append("private List<");
        Entity _referencedEntity_1 = r.getReferencedEntity();
        String _name_1 = _referencedEntity_1.getName();
        _builder.append(_name_1, "");
        _builder.append("> ");
        String _name_2 = r.getName();
        _builder.append(_name_2, "");
        _builder.append("= new ArrayList<");
        Entity _referencedEntity_2 = r.getReferencedEntity();
        String _name_3 = _referencedEntity_2.getName();
        _builder.append(_name_3, "");
        _builder.append(">();");
        _builder.newLineIfNotEmpty();
      } else {
        _builder.append("private ");
        Entity _referencedEntity_3 = r.getReferencedEntity();
        String _name_4 = _referencedEntity_3.getName();
        _builder.append(_name_4, "");
        _builder.append(" ");
        String _name_5 = r.getName();
        _builder.append(_name_5, "");
        _builder.append(";");
        _builder.newLineIfNotEmpty();
      }
    }
    _builder.newLine();
    return _builder;
  }
  
  public CharSequence compilegetset(final Attribute a) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("public ");
    Type _type = a.getType();
    String _name = _type.getName();
    _builder.append(_name, "");
    _builder.append(" get");
    String _name_1 = a.getName();
    String _firstUpper = StringExtensions.toFirstUpper(_name_1);
    _builder.append(_firstUpper, "");
    _builder.append("(){");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("return ");
    String _name_2 = a.getName();
    _builder.append(_name_2, "	");
    _builder.append(";");
    _builder.newLineIfNotEmpty();
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("public void set");
    String _name_3 = a.getName();
    String _firstUpper_1 = StringExtensions.toFirstUpper(_name_3);
    _builder.append(_firstUpper_1, "");
    _builder.append("(");
    Type _type_1 = a.getType();
    String _name_4 = _type_1.getName();
    _builder.append(_name_4, "");
    _builder.append(" ");
    String _name_5 = a.getName();
    _builder.append(_name_5, "");
    _builder.append("){");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("this.");
    String _name_6 = a.getName();
    _builder.append(_name_6, "	");
    _builder.append(" = ");
    String _name_7 = a.getName();
    _builder.append(_name_7, "	");
    _builder.append(";");
    _builder.newLineIfNotEmpty();
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    return _builder;
  }
  
  public CharSequence compilegetset(final Reference r) {
    StringConcatenation _builder = new StringConcatenation();
    {
      boolean _operator_or = false;
      Multiplicity _multiplicity = r.getMultiplicity();
      boolean _operator_equals = ObjectExtensions.operator_equals(_multiplicity, Multiplicity.MANY_TO_MANY);
      if (_operator_equals) {
        _operator_or = true;
      } else {
        Multiplicity _multiplicity_1 = r.getMultiplicity();
        boolean _operator_equals_1 = ObjectExtensions.operator_equals(_multiplicity_1, Multiplicity.ONE_TO_MANY);
        _operator_or = BooleanExtensions.operator_or(_operator_equals, _operator_equals_1);
      }
      if (_operator_or) {
        _builder.append("public List<");
        Entity _referencedEntity = r.getReferencedEntity();
        String _name = _referencedEntity.getName();
        _builder.append(_name, "");
        _builder.append("> get");
        String _name_1 = r.getName();
        String _firstUpper = StringExtensions.toFirstUpper(_name_1);
        _builder.append(_firstUpper, "");
        _builder.append("(){");
        _builder.newLineIfNotEmpty();
        _builder.append("\t");
        _builder.append("return ");
        String _name_2 = r.getName();
        _builder.append(_name_2, "	");
        _builder.append(";");
        _builder.newLineIfNotEmpty();
        _builder.append("}");
        _builder.newLine();
        _builder.newLine();
        _builder.append("public void set");
        String _name_3 = r.getName();
        String _firstUpper_1 = StringExtensions.toFirstUpper(_name_3);
        _builder.append(_firstUpper_1, "");
        _builder.append("(List<");
        Entity _referencedEntity_1 = r.getReferencedEntity();
        String _name_4 = _referencedEntity_1.getName();
        _builder.append(_name_4, "");
        _builder.append("> ");
        String _name_5 = r.getName();
        _builder.append(_name_5, "");
        _builder.append("){");
        _builder.newLineIfNotEmpty();
        _builder.append("\t");
        _builder.append("this.");
        String _name_6 = r.getName();
        _builder.append(_name_6, "	");
        _builder.append(" = ");
        String _name_7 = r.getName();
        _builder.append(_name_7, "	");
        _builder.append(";");
        _builder.newLineIfNotEmpty();
        _builder.append("}");
        _builder.newLine();
      } else {
        _builder.append("public ");
        Entity _referencedEntity_2 = r.getReferencedEntity();
        String _name_8 = _referencedEntity_2.getName();
        _builder.append(_name_8, "");
        _builder.append(" get");
        String _name_9 = r.getName();
        String _firstUpper_2 = StringExtensions.toFirstUpper(_name_9);
        _builder.append(_firstUpper_2, "");
        _builder.append("(){");
        _builder.newLineIfNotEmpty();
        _builder.append("\t");
        _builder.append("return ");
        String _name_10 = r.getName();
        _builder.append(_name_10, "	");
        _builder.append(";");
        _builder.newLineIfNotEmpty();
        _builder.append("}");
        _builder.newLine();
        _builder.newLine();
        _builder.append("public void set");
        String _name_11 = r.getName();
        String _firstUpper_3 = StringExtensions.toFirstUpper(_name_11);
        _builder.append(_firstUpper_3, "");
        _builder.append("(");
        Entity _referencedEntity_3 = r.getReferencedEntity();
        String _name_12 = _referencedEntity_3.getName();
        _builder.append(_name_12, "");
        _builder.append(" ");
        String _name_13 = r.getName();
        _builder.append(_name_13, "");
        _builder.append("){");
        _builder.newLineIfNotEmpty();
        _builder.append("\t");
        _builder.append("this.");
        String _name_14 = r.getName();
        _builder.append(_name_14, "	");
        _builder.append(" = ");
        String _name_15 = r.getName();
        _builder.append(_name_15, "	");
        _builder.append(";");
        _builder.newLineIfNotEmpty();
        _builder.append("}");
        _builder.newLine();
      }
    }
    _builder.append("\t");
    _builder.newLine();
    return _builder;
  }
  
  public void countenums(final Enumeration x) {
    EList<EnumerationLiteral> _literals = x.getLiterals();
    for (final EnumerationLiteral f : _literals) {
      int _operator_plus = IntegerExtensions.operator_plus(this.enumnum, 1);
      this.enumnum = _operator_plus;
    }
  }
  
  public CharSequence compile(final Enumeration x, final system.System s) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package ");
    String _packageName = s.getPackageName();
    _builder.append(_packageName, "");
    _builder.append(".entities;");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.newLine();
    _builder.append("public enum Category {");
    _builder.newLine();
    {
      EList<EnumerationLiteral> _literals = x.getLiterals();
      for(final EnumerationLiteral f : _literals) {
        {
          EList<EnumerationLiteral> _literals_1 = x.getLiterals();
          EnumerationLiteral _last = IterableExtensions.<EnumerationLiteral>last(_literals_1);
          boolean _equals = f.equals(_last);
          if (_equals) {
            _builder.append("\t");
            String _name = f.getName();
            _builder.append(_name, "	");
            _builder.newLineIfNotEmpty();
          } else {
            _builder.append("\t");
            String _name_1 = f.getName();
            _builder.append(_name_1, "	");
            _builder.append(",");
            _builder.newLineIfNotEmpty();
          }
        }
      }
    }
    _builder.append("}");
    _builder.newLine();
    return _builder;
  }
}
